extends StateBase


var unit: UnitVampire

func on_enter(owner = null, params = null):
	unit = owner as UnitVampire
	unit.is_in_bat_state = true
	unit.summon_bats()
	
	# hide vampire 
	unit.velocity = Vector2.ZERO
	var tween_alpha = create_tween()
	tween_alpha.tween_property(unit.view_root, "modulate:a", 0, 0.3) \
	.set_trans(Tween.TRANS_SINE) \
	.set_ease(Tween.EASE_IN_OUT).from_current()
	unit.disable_hurt_collision()
	unit.disable_body_collision()
	unit.disable_hit_collision()
	
	await get_tree().create_timer(unit.bat_state_duration).timeout
	if not unit.is_dead:
		unit.states.transition("Recover")
	

func on_exit(owner = null):
	pass


func on_process(delta: float, owner = null):
	pass
	
	
func on_physics_process(delta: float, owner = null):
	unit.process_bat_state_enter_death()
	
